From: Claudio Cambra Date: Thu, 28 Nov 2024 09:58:23 +0000 (+0800) Subject: Use std::prev ove -1ing the iterator X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~2^2~173^2~10 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=f2d49f5591837fe315c158c5a699a9ccbc9a820e;p=nextcloud-desktop.git Use std::prev ove -1ing the iterator Signed-off-by: Claudio Cambra Use std::prev for it rather than -1 in Syncengine Signed-off-by: Claudio Cambra --- diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 4d8f57dfb..927a248da 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1824,7 +1824,7 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item) QString fileSlash = item->_file + '/'; auto forbiddenIt = _discoveryData->_forbiddenDeletes.upperBound(fileSlash); if (forbiddenIt != _discoveryData->_forbiddenDeletes.begin()) - forbiddenIt -= 1; + forbiddenIt = std::prev(forbiddenIt); if (forbiddenIt != _discoveryData->_forbiddenDeletes.end() && fileSlash.startsWith(forbiddenIt.key())) { item->_instruction = CSYNC_INSTRUCTION_NEW; diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index f691ce09d..368d0f8c8 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -1205,8 +1205,8 @@ bool SyncEngine::wasFileTouched(const QString &fn) const // Start from the end (most recent) and look for our path. Check the time just in case. auto begin = _touchedFiles.constBegin(); for (auto it = _touchedFiles.constEnd(); it != begin; --it) { - if ((it-1).value() == fn) - return std::chrono::milliseconds((it-1).key().elapsed()) <= s_touchedFilesMaxAgeMs; + if (const auto prevIt = std::prev(it); prevIt.value() == fn) + return std::chrono::milliseconds(prevIt.key().elapsed()) <= s_touchedFilesMaxAgeMs; } return false; }